#include <cmdWriteFileData.h>
#include <devFileOpt.h>
void masterCmdCvrtFuncName(WriteFileData)(struct masterCmdStructName(WriteFileData) *masterData)
{
    convertOvtBigSysI16Pro(masterData->datasize);
    convertOvtBigSysI32Pro(masterData->foffset);
}
void devCmdCvrtFuncName(WriteFileData)(struct devCmdStructName(WriteFileData) *devData)
{
    devData = NULL;
}
int devCmdDealFuncName(WriteFileData)(struct ptcCmdOptStruct *cmdOpt)
{
    struct masterCmdStructName(WriteFileData) *masterData = ptcCmdGetUsrPtr(cmdOpt);
    struct devCmdStructName(WriteFileData) *devData = ptcCmdGetUsrPtr(cmdOpt);
    int tmpResult = cmdExeRslt_OK;
    if(ptcCmdGetUserSize(cmdOpt) < sizeof(struct masterCmdStructName(WriteFileData)))
    {
        logerror("%d", ptcCmdGetUserSize(cmdOpt));
        tmpResult = cmdExeRslt_MasterSizeErr;
        goto cmdDealErrorResp;
    }
    // do user logic

    if(devFileWriteData(foptInst(), masterData->foffset, masterData->fdata, masterData->datasize) < 0)
    {
        logerror("");
        tmpResult = cmdExeRslt_Fail;
        goto cmdDealErrorResp;
    }

    // pack response user data
    if(ptcCmdSetUsrSize(cmdOpt, sizeof(struct devCmdStructName(WriteFileData))) < 0)
    {
        logerror("%d", sizeof(struct devCmdStructName(WriteFileData)));
        tmpResult = cmdExeRslt_DevSizeErr;
        goto cmdDealErrorResp;
    }
cmdDealErrorResp:
    // pack response cmd head
    if(tmpResult != cmdExeRslt_OK)
    {
        ptcCmdSetUsrSize(cmdOpt, 0);
    }
    ptcCmdSetCmdResp(cmdOpt, tmpResult);
    ptcPackSetCrypte(&cmdOpt->parser, protocolParseCrypte_None);// set crypte type if you want
    // pack pack head by 485 cmd function. there not config
    return 0;
}

